package com.dynamixsoftware.printershare.smb;

import com.dynamixsoftware.printershare.smb.util.Dumper;
import java.io.UnsupportedEncodingException;

class SmbComTreeConnectAndX
  extends AndXServerMessageBlock
{
  private static final boolean DISABLE_PLAIN_TEXT_PASSWORDS = true;
  private static byte[] batchLimits = { 1, 1, 1, 1, 1, 1, 1, 1, 0 };
  private boolean disconnectTid = false;
  private byte[] password;
  private int passwordLength;
  String path;
  private String service;
  private SmbSession session;
  
  SmbComTreeConnectAndX(SmbSession paramSmbSession, String paramString1, String paramString2, ServerMessageBlock paramServerMessageBlock)
  {
    super(paramServerMessageBlock);
    this.session = paramSmbSession;
    this.path = paramString1;
    this.service = paramString2;
    this.command = 117;
  }
  
  int getBatchLimit(byte paramByte)
  {
    switch (paramByte & 0xFF)
    {
    default: 
      return 0;
    case 16: 
      return batchLimits[0];
    case 0: 
      return batchLimits[2];
    case 6: 
      return batchLimits[3];
    case 1: 
      return batchLimits[4];
    case 45: 
      return batchLimits[5];
    case 7: 
      return batchLimits[6];
    case 37: 
      return batchLimits[7];
    }
    return batchLimits[8];
  }
  
  int readBytesWireFormat(byte[] paramArrayOfByte, int paramInt)
  {
    return 0;
  }
  
  int readParameterWordsWireFormat(byte[] paramArrayOfByte, int paramInt)
  {
    return 0;
  }
  
  public String toString()
  {
    return new String("SmbComTreeConnectAndX[" + super.toString() + ",disconnectTid=" + this.disconnectTid + ",passwordLength=" + this.passwordLength + ",password=" + Dumper.toHexString(this.password, this.passwordLength, 0) + ",path=" + this.path + ",service=" + this.service + "]");
  }
  
  int writeBytesWireFormat(byte[] paramArrayOfByte, int paramInt)
  {
    if ((this.session.transport.server.security == 0) && ((this.session.auth.hashesExternal) || (this.session.auth.password.length() > 0))) {
      System.arraycopy(this.password, 0, paramArrayOfByte, paramInt, this.passwordLength);
    }
    int i;
    for (int j = paramInt + this.passwordLength;; j = i)
    {
      int k = j + writeString(this.path, paramArrayOfByte, j);
      try
      {
        System.arraycopy(this.service.getBytes("ASCII"), 0, paramArrayOfByte, k, this.service.length());
        int m = k + this.service.length();
        int n = m + 1;
        paramArrayOfByte[m] = 0;
        return n - paramInt;
      }
      catch (UnsupportedEncodingException localUnsupportedEncodingException) {}
      i = paramInt + 1;
      paramArrayOfByte[paramInt] = 0;
    }
    return 0;
  }
  
  int writeParameterWordsWireFormat(byte[] paramArrayOfByte, int paramInt)
  {
    int i = 1;
    int j;
    if ((this.session.transport.server.security == 0) && ((this.session.auth.hashesExternal) || (this.session.auth.password.length() > 0))) {
      if (this.session.transport.server.encryptedPasswords)
      {
        this.password = this.session.auth.getAnsiHash(this.session.transport.server.encryptionKey);
        this.passwordLength = this.password.length;
        j = paramInt + 1;
        if (!this.disconnectTid) {
          break label157;
        }
      }
    }
    for (;;)
    {
      paramArrayOfByte[paramInt] = i;
      int k = j + 1;
      paramArrayOfByte[j] = 0;
      writeInt2(this.passwordLength, paramArrayOfByte, k);
      return 4;
      throw new RuntimeException("Plain text passwords are disabled");
      this.passwordLength = i;
      break;
      label157:
      i = 0;
    }
  }
}


/* Location:           C:\Users\Admin\Desktop\Decompiler\JAD\jd-gui-0.3.6.windows\classes_dex2jar.jar
 * Qualified Name:     com.dynamixsoftware.printershare.smb.SmbComTreeConnectAndX
 * JD-Core Version:    0.7.0.1
 */